import Axios from './core/Axios'
import * as utils from './utils'
import bind from './helpers/bind'
import defaults from './defaults'

/**
 * 实现 axios({}) 以及 axios.get() 等功能
 * @param defaultConfig 
 */
function createInstance(defaultConfig: DefaultsConfigs): AxiosStatic {
    var context = new Axios(defaultConfig);
    var instance = bind(Axios.prototype.request, context);
    // 继承 axios.prototype
    utils.extend(instance, Axios.prototype, context);
    // 继承 context
    utils.extend(instance, context);
    return (instance as any as AxiosStatic);
}
const axios = createInstance(defaults);
axios.Axios = Axios;
axios.interceptors.request.use((data) => {
    console.log('request')
    return Promise.resolve(data)
}, () => {})

axios.interceptors.response.use((data) => {
    console.log('response')
    return Promise.resolve(data)
}, () => {})

axios.get('https://testop.xhwx100.com/gorilla/api/v2.0/tutor/organization/list?type_code=1')